package com.example.toy.core.utils;

import com.example.toy.core.filter.Filters;
import com.example.toy.core.filter.ToyFilter;
import com.example.toy.core.format.ToyHiddenFields;
import com.example.toy.core.record.key.ToyRecordKey;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericRecord;

public class RecordKeyHelper {


  public static ToyFilter toToyFilter(ToyRecordKey key) {
    Filters.EqualFilter keyFilter = new Filters.EqualFilter(ToyHiddenFields.TOY_INTERNAL_RECORD_KEY, key.getRawKey());
    Filters.EqualFilter partitionFilter = new Filters.EqualFilter(ToyHiddenFields.TOY_INTERNAL_PARTITION_KEY, key.getPartitionKey());
    return keyFilter.and(partitionFilter);
  }
}
